package com.leung.mybatis.session.defaults;


import com.leung.mybatis.binding.MapperRegistry;
import com.leung.mybatis.session.SqlSession;

/**
 * @author 丨一
 * @version 1.0
 * @title DefualtSqlSession
 * @description:
 * @date 2025/10/8 下午2:55
 */
public class DefaultSqlSession implements SqlSession {

    private MapperRegistry mapperRegistry;

    public DefaultSqlSession(MapperRegistry mapperRegistry) {
        this.mapperRegistry = mapperRegistry;
    }

    @Override
    public <T> T selectOne(String statement) {
        return (T) ("你被代理了" + statement);
    }

    @Override
    public <T> T selectOne(String statement, Object parameter) {
        return (T) ("你被代理了!" + "方法: " + statement + "入参: " + parameter);
    }

    @Override
    public <T> T getMapper(Class<T> type) {
        return mapperRegistry.getMapper(type, this);
    }
}
